
$(document).ready(function(){
	/*弹框*/
			var left = ((document.body.clientWidth) - 435)/2;
			function pop(){
				$('.pop').css('left',left)
				$('.pop1').css('display','block');
				$('.pop').css('display','block');
			};
			function pop1(){
				$('.pop1').css('display','none');
				$('.pop').css('display','none');
			};
			$('.pop-img').click(function(){
				pop1();
			});
			$('.pop-y').click(function(){
				pop1();
			});
			/*弹框结束*/
	var sex;
    $('.mine_select').on('click',function(e){
//		alert(11);
//		$('.mine_select_all').css('border','none');
		$('.how_old_d').css('display','block');
		e.stopPropagation();
	})
	
	
	$('.occup_select').on('click',function(e){
//		alert(11);
//		$('.occup_select_all').css('border','none');
		$('.occup_old_d').css('display','block');
		e.stopPropagation();
	})
	
	/*关闭弹窗交互*/
	document.onclick=function(){

        $('.occup_old_d').css('display','none');
		$('.how_old_d').css('display','none');
    }
	
	/*个人中心职业选择点击交互*/
	$('.occup_old_dc>span').on('click',function(){
		     $('.occup_select').text($(this).text()) ;       
	})
	
	$('.how_old_dc').on('click','span',function(){
		     $('.mine_select').text($(this).text()) ;       
	})
	
	
	/*个人中心点击交互*/
	$('.mine_mail_con').on('click',function(){
		$('.mine_mail').css('border','4px solid #ffc100');
		$('.mine_famail').css('border','1px solid #b6b6b6');
		sex=1;
	});
	
	$('.mine_famail_con').on('click',function(){
		$('.mine_famail').css('border','4px solid #ffc100');
		$('.mine_mail').css('border','1px solid #b6b6b6');
		sex=0;
	});
	
	
	var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;   //height
    var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;      //width
//	alert(h);
//	alert(w);
    $('.mineloogwuliu').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.minetxfgoods').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.minedeleorder').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.minesureget').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.editor_address_d').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.minedorder').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.mineback').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.ifdeleorder').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
    $('.mine_complainsuccess').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
	$('.creat_address_d').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
	$('.confirmOrderdiv').css({'width':w,"height":h,"top":"0","left":"0","position":"fixed"});
	
	
	$('.creat_nagiv').on('click',function(){
		$('.creat_address_d').css('display','none');
		$(this).parents('body').css({"height":"100%","overflow": "auto"});
		$(this).parents('html').css({"height":"100%","overflow": "auto"});
	})

    $('.mbackg').on('click',function(){
    	$(this).parents('.mineback').css('display','none');
    })

	
	/*投诉建议查看详情交互*/
//	$('.cpmplain_type>span').on('click',function(){
//		$(this).css({"color":"#ff5350","border-bottom":"2px solid #ff5350"});
//		$(this).siblings().css({"color":"black","border-bottom":"none"})
//	})
	
	
	/*投诉建议查看详情交互*/
	$('.cpmplain_type_con2').on('click','.cpmplain_dinfo_more',function(){
	
		$(this).parents('.cpmplain_type_con2_dan').find('.cpmplain_info_details').toggle();
		if($(this).text()=="展开"){
			$(this).text("关闭");
		}else if($(this).text()=="关闭"){
			$(this).text("展开");
		}
	})
	
	/*用户帮助点击查看详情交互*/
	$('.helper_dinfo_more').on('click',function(){
		$(this).parents('.helper_type_con2_dan').find('.helper_info_details').toggle();
		if($(this).text()=="展开"){
			$(this).text("关闭");
		}else if($(this).text()=="关闭"){
			$(this).text("展开");
		}
	})
	
	
	/*投诉建议tab切换*/
	$('.cpmplain_type>span').on('click',function(){
		$('.cpmplain_type_con>div').eq($(this).index()).css('display','block');
		$('.cpmplain_type_con>div').eq($(this).index()).siblings().css('display','none');
		$(this).css({"color":"#ff5350","border-bottom":"2px solid #ff5350"});
		$(this).siblings().css({"color":"black","border-bottom":"none"});
	})
	
	/*点击修改昵称*/
	$('.modifiy').on('click',function(){
		if($(this).text()=='修改'){
		$('.inmine_surename').val($('.mine_surename').text());	
		$('.mine_surename').css('display','none');
		$('.inmine_surename').css('display','inline-block');
		$(this).text('确认');
	  }else if($(this).text()=='确认'){
	  	if($('.inmine_surename').val()==''){
			$('.nichengtips').css('visibility','visible').text('请输入昵称');
		}else{
		  	$('.mine_surename').text($('.inmine_surename').val());
		  	$('.inmine_surename').css('display','none');
			$('.mine_surename').css('display','inline-block');
			$(this).text('修改');
		}
	  }
	})
	
	$('.inmine_surename').focus(function(){
		
		$('.nichengtips').css('visibility','hidden');
	})
	
	
	$('.inmine_surename').blur(function(){
		if($('.inmine_surename').val()==''){
			$('.nichengtips').css('visibility','visible');
		}
		
	})
	
	$('.select_type_comliain').on('click','span',function(){
		
		$(this).find('span').addClass("borderselected");
		$(this).siblings().find('span').removeClass("borderselected");
		sessionStorage.wyshopwhtype=$(this).attr('id');
	})
	
	

	
	/*整个页面交互*/
	$(function(){
		get_mine_info();
		if(localStorage.wyshopwheretopage==2){
			$('.cmine_order1').css('color','#FFC100');
			$('.mine_order').css('display','block');
			$('.o_type').text('全部订单');
			localStorage.status='';
			orderList(1);
		}else if(localStorage.wyshopwheretopage==3){
			$('.cmine_order2').css('color','#FFC100');
			$('.mine_order').css('display','block');
			$('.o_type').text('待付款');
			localStorage.status=1;
			orderList(1);
		}else if(localStorage.wyshopwheretopage==4){
			$('.cmine_order3').css('color','#FFC100');
			$('.mine_order').css('display','block');
			$('.o_type').text('待发货');
			localStorage.status=2;
			orderList(1);
		}else if(localStorage.wyshopwheretopage==5){
			$('.cmine_order4').css('color','#FFC100');
			$('.mine_order').css('display','block');
			$('.o_type').text('待收货');
			localStorage.status=3;
			orderList(1);
		}else if(localStorage.wyshopwheretopage==6){
			$('.cmine_order5').css('color','#FFC100');
			$('.mine_order').css('display','block');
			$('.o_type').text('待评论');
			localStorage.status=5;
			orderList(1);
		}else if(localStorage.wyshopwheretopage==1){
			$('.cmine_infor').css('color','#FFC100');
			$('.mine_infor').css('display','block');
			
			
		   
		}else if(localStorage.wyshopwheretopage==7){
			$('.cmine_welfare').css('color','#FFC100');
			$('.mine_welfare').css('display','block');
		    listzhang(1);
		}else if(localStorage.wyshopwheretopage==8){
			$('.cmine_wallet').css('color','#FFC100');
			$('.mine_wallet').css('display','block');
		    getmoney();
		    bill(1);
		}else if(localStorage.wyshopwheretopage==9){
			$('.cuse_helper').css('color','#FFC100');
			$('.use_helper').css('display','block');		   
		}else if(localStorage.wyshopwheretopage==10){
			$('.cmine_complain').css('color','#FFC100');
			$('.mine_complain').css('display','block');		
			 getmyjy();
		}else if(localStorage.wyshopwheretopage==11){
			$('.cmy_address').css('color','#FFC100');
			$('.my_address').css('display','block');		
			showlist();
		}else if(localStorage.wyshopwheretopage==12){
			$('.cmine_modify').css('color','#FFC100');
			$('.mine_modify').css('display','block');		
			
		}else if(localStorage.wyshopwheretopage==13){
			$('.cmine_back').css('color','#FFC100');
			$('.mine_back').css('display','block');
			localStorage.noStatesStr = '5';
			localStorage.refundType = '13';
			localStorage.price = '';
			
			tuihuo();
		}
	})
	
	
	
	
	
	
	
	/*我的页面点击交互*/
	$('.cmine_infor').on('click',function(){
		$('.mine_infor').css('display','block');
		$('.mine_infor').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		get_mine_info();
	})
	
	$('.cmine_order').on('click',function(){
		$('.order_all').html('');
		$('.classpagen').html('');
		$('.mine_order').css('display','block');
		$('.mine_order').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		$('.o_type').text($(this).text());
		$('.classpage').css('display','block');

		if($(this).text()=='全部订单'){
			localStorage.wyshopwhereto=2;
			localStorage.status='';
			orderList();
			
		}else if($(this).text()=='待付款'){
			localStorage.wyshopwhereto=3;
			localStorage.status=1;
			orderList();
		}else if($(this).text()=='待发货'){
			localStorage.wyshopwhereto=4;
			localStorage.status=2;
			orderList();
		}else if($(this).text()=='待收货'){
			localStorage.wyshopwhereto=5;
			localStorage.status=3;
			orderList();
		}else if($(this).text()=='待评论'){
			localStorage.wyshopwhereto=6;
			localStorage.status=5;
			orderList();
		}
		
	})
	
	$('.cmine_welfare').on('click',function(){
		$('.conpain_all').html('');
		$('.classpagen').html('');
		$('.mine_welfare').css('display','block');
		$('.mine_welfare').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		listzhang();
		
		localStorage.wyshopwhereto=7;
	});
	
	$('.cmine_wallet').on('click',function(){
		$('.my_bill_con').html('');
		$('.classpagen').html('');
		$('.mine_wallet').css('display','block');
		$('.mine_wallet').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		getmoney();
		bill();
		
		localStorage.wyshopwhereto=8;
	});
	
	$('.cuse_helper').on('click',function(){
		$('.use_helper').css('display','block');
		$('.use_helper').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
	})
	
	$('.cmine_complain').on('click',function(){
		$('.mine_complain').css('display','block');
		$('.mine_complain').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		getmyjy();
	})
	
	$('.cmy_address').on('click',function(){
		$('.my_address').css('display','block');
		$('.my_address').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		showlist();
	})
	
	$('.cmine_modify').on('click',function(){
		$('.mine_modify').css('display','block');
		$('.mine_modify').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
	})
	
	$('.cmine_back').on('click',function(){
		$('.mbtuihuo').html('');
			$('.btuikuang').html('');
		$('.mine_back').css('display','block');
		$('.mine_back').siblings().css('display','none');
		$('.mbig').css('color','#333333');
		$('.mmin').css('color','#787878');
		$(this).css('color','#FFC100');
		
		localStorage.noStatesStr = '5';
			localStorage.refundType = '13';
			localStorage.price = '';
			$('.tui1').html('');
			tuihuo();
	})
    
    //判断是否为企业员工
    ifqiye();
    function ifqiye(){
    	
    	if(localStorage.wyshopisAdmin!='' && localStorage.wyshopisAdmin==2){
          	
          	$('.cmine_welfare').css('display','block');
          }else if(localStorage.wyshopisAdmin!='' && localStorage.wyshopisAdmin==1){
          	
          	$('.cmine_welfare').css('display','none');
          }else if(localStorage.wyshopisAdmin ==''){
//                	alert('空');
          	$('.cmine_welfare').css('display','none');
          }
    }
    
    
    
        //充值
     $('.minetochong').on('click',function(){
//   	alert(11);
          localStorage.wyshopifRecharge = 1;
     	  window.location.href='../cart/pay.html';
     })



//       var mine_infororder = $('.mine_infororder').css('width')+'px';
//       $('.mine_infors').css('width','mine_infororder');
	
	    
	
	         
			//获取资料接口页面1
//			get_mine_info();
			function get_mine_info(){
//				alert(111);
              
				$(function(){
					for(var agefor=16;agefor<71;agefor++){
						var agespan = $('<span>'+agefor+'</span>');
						$('.how_old_dc').append(agespan);
					}
				})


				$.ajax({
					url:ur+'/mobilemember/frontmember/getInfo',
					type:'post',
					dataType:'json',
					headers:{
						'X-Token':localStorage.wyshoptoken
					},
					data:'',
					success:function(data){
						
						

                 if(data.result.meta.code==200){
					   if(data.result.data.sex==1){
							$('.mine_mail').css('border','4px solid rgb(255, 193, 0)');		
							$('.mine_famail').css('border','1px solid rgb(182, 182, 182)');	
						}else{
							$('.mine_famail').css('border','4px solid rgb(255, 193, 0)');		
							$('.mine_mail').css('border','1px solid rgb(182, 182, 182)');		
						}
					
						$('.mine_hear_pic').css('background-image','url('+picur+data.result.data.headphoto+')');
						$('.mine_surename').text(data.result.data.nickName);
						$('.phone_numb_con').text(data.result.data.phone);
						if(data.result.data.age==null){
							$('.mine_select').text('请选择');
						}else if(data.result.data.age!=null){
						 	$('.mine_select').text(data.result.data.age);
						}
						if(data.result.data.job==null){
							$('.occup_select').text('请选择');
						}else if(data.result.data.job!=null){
						 	$('.occup_select').text(data.result.data.job);
						}
						
						$('.mine_hear_picnone').attr('src',picur+data.result.data.headphoto);
						
						$('.email74').attr('value',data.result.data.email)
						
					
						$('.thead_pic>span').css('background-image','url('+picur+data.result.data.headphoto+')');
						$('.mine_surename').text(data.result.data.nickName);
//						$('.tlogin').text(data.result.data.phone);
						}


					},
					error:function(e){
						console.log(JSON.stringify(e)+'0000');
					}
				})
			}
			
			
		    //提交个人信息
		    $('.preser').on('click',function(){
		    	
	            var yemail74 = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	            var emailVal = $('.email74').val();
	            if(emailVal==''){
	            	$('.email-tip').css('visibility','visible');
	            	$('.email-tip').text('邮箱不能为空');
	            }else if(!yemail74.test(emailVal)){
	            	$('.email-tip').css('visibility','visible');
	            	$('.email-tip').text('请填写符合规格的邮箱');
	            }else{
	            	if($('.modifiy').text()=='修改'){
			    		submitinfo();
			    	}
	            }
	
		    })
		    
		    $('#email74').focus(function(){
		    	/*alert(11);*/
		    	$('.email-tip').css('visibility','hidden');
		    })
	    
	        /*提交资料接口*/
	        function submitinfo(){

	            var imgPath = $('.mine_hear_picnone').attr('src');
//	            var avatar = $("#image-preview").css("backgroundImage");
  
//					imgPath = imgPath.split("(")[1].split(")")[0];
					  
//					alert(imgPath);
				if(sessionStorage.wyshopifmh&&sessionStorage.wyshopifmh==1){
					uploadHead(imgPath);
				}

					var nickname=localStorage.nickname;
					var age=$('.age').text();
					var job=$('.job').text();
							
					
				$.ajax({
					url:ur+'/mobilemember/frontmember/edit',
					type:'post',
					dataType:'json',
					headers:{
						'X-Token':localStorage.wyshoptoken
					},
					data:{
						'memberVO.nickName':$('.mine_surename').text(),
						'userInformationVO.job':$('.occup_select').text(),
						'userInformationVO.ufAgeRange':$('.mine_select').text(),
						'userInformationVO.ufSex':sex,
						'memberVO.email':$('.email74').val()
					},
					success:function(data){
			$('.pop-text').text('保存资料成功');
								pop();
						
					},
					error:function(e){
						console.log(e+'提交资料接口错误');
					}
				})
			}
	    
	    
	    
	   
	    function submithead(e){
//				alert(777);
				$.ajax({
					url:ur+'/mobilemember/frontmember/updateHeadPortrait',
					type:'post',
					dataType:'json',
					headers:{
						'X-Token':localStorage.wyshoptoken
					},		
					data:{
						'fileName':'head.jpg',
						'photo':e
					},
					success:function(data){
						console.log(JSON.stringify(data)+'头像');

                        
					},
					
					error:function(e){
						console.log(e)
						
					}
				})
			}
	    
	     
	    
	
	    function uploadHead(imgPath) {
//	    	alert(sessionStorage.wyshopifmh+"asd");
						var image = new Image();
						image.style.width = "100px";
						image.style.height = "100px";
						image.src = imgPath; //传过来的图片的路径
						image.onload = function() {
//							alert(666);
							var imgData = getBase64Image(image);
							submithead(imgData);
							sessionStorage.wyshopifmh=0;
						}
		}
	    
					//	压缩图片
		function getBase64Image(image) {
			var canvas = document.createElement("canvas"); //创建一个canvas节点
			var width = image.width;
			var height = image.height;
			canvas.width = width;
			canvas.height = height;
			var ctx = canvas.getContext('2d'); //创建canvas对象 
			ctx.drawImage(image, 0, 0, width, height); //绘图
			var dataURL = canvas.toDataURL("image/jpeg", 0.5);
			return dataURL;
		}
		
		
		$('.mbacksel>span').on('click',function(){
			$('.o_backg').text($(this).text());
			var index = $(this).index();
			$('.mbtuihuo').html('');
			$('.btuikuang').html('');
			$('.mbtuihuoed').html('');
			$('.btuikuanged').html('');
			$(this).css({'color':'#ff5350', 'border-bottom':'2px solid #ff5350'});
			$(this).siblings().css({'color':'#333333', 'border-bottom':'none'});
			$('.minenackalldiv>div').eq($(this).index()).css('display','block');
			$('.minenackalldiv>div').eq($(this).index()).siblings().css('display','none');
			
			if(index == 0) {
						localStorage.noStatesStr = '5';
						localStorage.refundType = '13';
						localStorage.price = '';
						$('.tui1').html('');
						tuihuo();
					} else if(index == 1) {
						localStorage.noStatesStr = '15,19';
						localStorage.refundType = '13';
						localStorage.price = '';
						$('.tui2').html('');
						tuihuo();
					} else if(index == 2) {
						$('.kuan1').html('');
						localStorage.refunded = '8';
						localStorage.price = '';
						tuikuan();
					} else {
						$('.kuan2').html('');
						localStorage.refunded = '7';
						localStorage.price = '';
						tuikuan();
					}
			
			
		})
		
		
		
		/*分页逻辑*/
		var guepage;
		function classpage(){
//			alert(allpage);	
            var p = new Page('page');
			//总记录数
			p.recordCount = sessionStorage.wyShopPase;
			//分页按扭数
			p.numericButtonCount = 4;
			//每页记录数YW
			p.pageSize = 5;
			//当点击分页时触发此事件。 一些外加的效果可以放在此处， 如加载数据
			p.addListener('pageChanged', function() {
//				alert('第' + p.pageIndex + '页');
				p.render();
				$('.order_all').html('');
				orderListshi();
			});
			p.initialize();
		
		   function orderListshi(){
		   	
		   
		       $.ajax({
					//					url: ur + 'mobilemember/frontOrder/orderlist',
					url: ur + '/mobilemember/frontOrder/orderlist',
					type: 'post',
					dataType: 'json',
					headers: {
						'X-Token': localStorage.wyshoptoken,
					},
					data: {
						'orderVO.status': localStorage.status,
						'numPerPage':p.pageSize,
						'pageNum':p.pageIndex,
						'pageRequest':1
						//								'status':status
					},
					success: function(data){
						sessionStorage.wyShopPase = data.paginator.totalCount;
//						if(guepage==data.paginator.totalPage){
//							sessionStorage.ifhaveor = 0;
//							$('.mui-pull-loading').text('没有更多');
//						 }else if(guepage<data.paginator.totalPage){
//						 	sessionStorage.ifhaveor = 1;
//						 }
						//商品叠加
                        guepage =p.pageIndex;
						//								console.log(m+'第二个的长度');
                         
                         if(data.result.meta.code == 200) {
							
							
							
//							classpage(data.paginator.totalPage,data.paginator.pageIndex);
							
							pageindexb = data.paginator.pageIndex;
							var n = data.result.data.length;
                                 
							for(var i = 0; i < n; i++) {
								
								var howjian = 0;
								var allpric = 0;
								
								
								
								
								var divall = $('<div class="order_dan" oid="' + data.result.data[i][0].orderId + '"  onum="' + data.result.data[i][0].orderNum + '">'+
								'<div class="order_zt"><span class="order_date">' + data.result.data[i][0].createTime.replace(/T/, '  ') + '</span><span class="order_num">订单号：<span class="order_number">' + data.result.data[i][0].orderNum + '</span></span><span class="order_typesi fukuan'+i+guepage+''+0+'">待发货</span></div>'+
								'<div  class="order_danall order-all'+i+guepage+'">'+
//									'<div class="order_consig">'+
//										'<div class="mine_infors">'+
//											'<span></span>'+
//											'<div class="goods_shux">'+
//												'<p class="goods_name">阿斯顿阿斯顿发送撒旦法师打发斯蒂芬发士大夫撒旦飞洒地方撒旦 </p>'+
//												'<p class="goods_type">类型：红色罐装</p>'+
//											'</div>'+
//										'</div>'+
//										'<div class="sign_ps">￥<span>120.00</span></div>'+
//										'<div class="timess">6</div>'+
//										'<div class="all_pris">￥<span>120.00</span></div>'+
//										
//									'</div>'+
								'</div>'+
								'<div class="operes">'+
								            '<div class="lookdetails">查看详情</div>'+  
											'<div ifconf="' + data.result.data[i][0].isConfirm + '" class="mbuttom1 payment'+i +guepage+''+0+'"></div>'+
											'<div class="mbuttom2 delete'+i+guepage+''+0+'"></div>'+
								'</div>'+
							'</div>');
								
								
                                $('.order_all').append(divall);
								if(localStorage.status == 1) {
									//									$('.a1').html('');
									
									$('.fukuan' + i + guepage+ '' + 0 + '').text('等待买家付款');
									$('.delete' + i + guepage+ '' + 0 + '').text('取消订单');
									$('.payment' + i + guepage+ '' + 0 + '').text('立即支付');
								} else if(localStorage.status == 2 || localStorage.status == 19) {
									//									$('.a2').html('');
									
									$('.fukuan' + i + guepage+ '' + 0 + '').text('买家已付款');
									$('.delete' + i + guepage+ '' + 0 + '').text('申请退款');
									$('.payment' + i + guepage+ '' + 0 + '').text('提醒发货');
									
									if($('.payment' + i + guepage+ '' + 0 + '').attr('ifconf')==0){
										$('.payment' + i + guepage+ '' + 0 + '').text('确认订单');
										$('.payment' + i + guepage+ '' + 0 + '').removeClass('mbuttom1').addClass('confirmOrder');
									}else if($('.payment' + i + guepage+ '' + 0 + '').attr('ifconf')==1){
										$('.payment' + i + guepage+ '' + 0 + '').text('提醒发货');
										$('.payment' + i + guepage+ '' + 0 + '').removeClass('confirmOrder').addClass('mbuttom1');
									}
									
								} else if(localStorage.status == 3) {
									//									$('.a3').html('');
									
									$('.fukuan' + i + guepage+ '' + 0 + '').text('卖家已发货');
									$('.delete' + i + guepage+ '' + 0 + '').text('查看物流');
									$('.payment' + i + guepage+ '' + 0 + '').text('确认收货');
								} else if(localStorage.status == 5) {
									//									$('.a4').html('');
									
									$('.fukuan' + i + guepage+ '' + 0 + '').text('交易成功');
									$('.delete' + i + guepage+ '' + 0 + '').text('删除订单');
									$('.payment' + i + guepage+ '' + 0 + '').css('display', 'none');
								} else if(localStorage.status == '') {
									//									$('.a0').html('');
									
									if(data.result.data[i][0].status == 1) {
										//									$('.a1').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('等待买家付款');
										$('.delete' + i + guepage+ '' + 0 + '').text('取消订单');
										$('.payment' + i + guepage+ '' + 0 + '').text('立即支付');
									} else if(data.result.data[i][0].status == 2 || data.result.data[i][0].status == 19) {
										//									$('.a2').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('买家已付款');
										$('.delete' + i + guepage+ '' + 0 + '').text('申请退款');
										$('.payment' + i + guepage+ '' + 0 + '').text('提醒发货');
										
										if($('.payment' + i + guepage+ '' + 0 + '').attr('ifconf')==0){
											$('.payment' + i + guepage+ '' + 0 + '').text('确认订单');
											$('.payment' + i + guepage+ '' + 0 + '').removeClass('mbuttom1').addClass('confirmOrder');
										}else if($('.payment' + i + guepage+ '' + 0 + '').attr('ifconf')==1){
											$('.payment' + i + guepage+ '' + 0 + '').text('提醒发货');
											$('.payment' + i + guepage+ '' + 0 + '').removeClass('confirmOrder').addClass('mbuttom1');
										}
										
									} else if(data.result.data[i][0].status == 3) {
										//									$('.a3').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('卖家已发货');
										$('.delete' + i + guepage+ '' + 0 + '').text('查看物流');
										$('.payment' + i + guepage+ '' + 0 + '').text('确认收货');
									} else if(data.result.data[i][0].status == 5) {
										//									$('.a4').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('交易成功');
										$('.delete' + i + guepage+ '' + 0 + '').text('删除订单');
										$('.payment' + i + guepage+ '' + 0 + '').css('display', 'none');
									} else if(data.result.data[i][0].status == 6) {
										//									$('.a4').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('交易关闭');
										$('.delete' + i + guepage+ '' + 0 + '').css('display', 'none');
										$('.payment' + i + guepage+ '' + 0 + '').css('display', 'none');
									}else if(data.result.data[i][0].status == 11) {
										//									$('.a2').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('交易关闭');
										$('.delete' + i + guepage+ '' + 0 + '').text('删除订单');
										$('.payment' + i + guepage+ '' + 0 + '').css('display', 'none');
									} else if(data.result.data[i][0].status == 9) {
										//									$('.a2').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').text('交易关闭');
										$('.delete' + i + guepage+ '' + 0 + '').text('删除订单');
										$('.payment' + i + guepage+ '' + 0 + '').css('display', 'none');
									} else if(data.result.data[i][0].status == 12) {
										//									$('.a2').html('');
										
										$('.fukuan' + i + guepage+ '' + 0 + '').parents('.order_dan').css('display', 'none');
										//										$('.delete' + i + '' + 0 + '').text('删除订单');
										//										$('.payment' + i + '' + 0 + '').css('display', 'none');
									} else if(data.result.data[i][0].status == 13) {
										//									$('.a2').html('');
										
										//										$('.fukuan' + i + '' + 0 + '').parents('#daifukuan').css('display', 'none');
										$('.fukuan' + i + guepage+ '' + 0 + '').text('退款中');
										$('.delete' + i + guepage+ '' + 0 + '').css('display', 'none');
										$('.payment' + i + guepage+ '' + 0 + '').css('display', 'none');
										//										$('.delete' + i + '' + 0 + '').text('删除订单');
										//										$('.payment' + i + '' + 0 + '').css('display', 'none');
									}
									//									$('.fukuan').text('交易成功');
									//									$('.delete').text('删除订单');
									//									$('.payment').text('待评价');
								}
								//							console.log(n + '循环第yi个的长度');
								for(var j = 0; j < data.result.data[i].length; j++) {
									//								console.log(data.result.data[i].length+j + '循环第二个的长度');
									//								var money_z = data.result.data[i][j].price * data.result.data[i][j].amount;
									//								$('.allpric'+i+'').text(money_z);
									var b = data.result.data[i][j].photoPath;
									console.log(b.indexOf(',') + '逗号索引值');
									var m = b.indexOf(',');
									if(m != '-1') {
										var mainImg = b.substring(0, m);
									} else {
										mainImg = b;
									}
									
									
									var div = $('<div class="order_consig order_consig'+i+j+'">'+
										'<div class="mine_infors">'+
											'<span style="background-image:url(' + picur + mainImg + ');background-position:center;background-repeat:no-repeat;background-size:cover;"></span>'+
											'<div class="goods_shux">'+
												'<p class="goods_name">' + data.result.data[i][j].shorName + ' </p>'+
												'<p class="goods_type">' + data.result.data[i][j].size + '</p>'+
											'</div>'+
										'</div>'+
										'<div class="sign_ps">￥<span>' + data.result.data[i][j].price + '</span></div>'+
										'<div class="timess">' + data.result.data[i][j].amount + '</div>'+
										'<div class="all_pris">￥<span>' + data.result.data[i][j].amount*data.result.data[i][j].price + '</span></div>'+
										
									'</div>');
									
									
//									var div = $(
//										'<div class="order-body">' +
//										'<div class="product">' +
//										'<div class="p-img" style="background-image:url(' + picur + mainImg + ');background-position:center;background-repeat:no-repeat;background-size:cover;"></div>' +
//										'<div class="details"><p>' + data.result.data[i][j].shorName + '</p><p class="d' + i +guepage+ '' + j + '">' + data.result.data[i][j].proVal + '</p><p>' + data.result.data[i][j].size + '</p></div>' +
//										'<div class="details_ri">' +
//										'<p  class="pr1'+ i + guepage+''+j+'">￥' + data.result.data[i][j].price + '</p>' +
//										'<p  class="pr2'+ i + guepage+''+j+'"><del>￥' + data.result.data[i][j].oriPrice + '</del></p>' +
//										'<p>X' + data.result.data[i][j].amount + '</p>' +
//										'<p class="yf'+ i + guepage+''+j+'">运费:<span>'+ data.result.data[i][j].freight +'</span></p>' +
//										'</div>' +
//										'</div>' +
//										'</div>'
//									);
									$('.order-all'+i+guepage+'').append(div);
									
									if(data.result.data[i][j].price==data.result.data[i][j].oriPrice){
										$('.pr2'+ i + guepage+''+j+'').css('display','none');
									}
									
									if(data.result.data[i][j].shorName=='会员充值'){
										$('.order_consig'+i+j+'').parents('.order_dan').css('display','none');
									}
									//									console.log(data.result.data[i][j].proVal);
									//								(data.result.data[i][j].proVal==undefined||data.result.data[i][j].proVal=="null"?data.result.data[i][j].proVal:'')
									
									if(data.result.data[i][j].proVal == "undefined" || data.result.data[i][j].proVal == null) {
										//									alert(1);
										//									alert($('.d'+i+''+j+''));
										//										console.log($('.d' + i + '' + j + ''));
										$('.d' + i +guepage+ '' + j + '').css('display', 'none');
									}
									if(data.result.data[i][j].freight == "undefined" || data.result.data[i][j].freight == null) {
										//									alert(1);
										//									alert($('.d'+i+''+j+''));
										//										console.log($('.d' + i + '' + j + ''));
										$('.yf'+ i + guepage+''+j+'').css('display', 'none');
									}
									howjian = howjian + data.result.data[i][j].amount;
									allpric = allpric + data.result.data[i][j].price * data.result.data[i][j].amount;
									$('.howjian' + i + guepage+ '').text(howjian);
//									$('.allpric' + i + guepage+ '').text(allpric);
									
                                     if(allpric==data.result.data[i][0].orderPrice){
                                     	
                                     	$('.allyouhuije'+i+ guepage+'').css('display','none');
                                     }else if(allpric!=data.result.data[i][0].orderPrice){
                                     	
//                                   	$('.allyouhuije').css('display','none');

                                     	$('.youhuije'+i+ guepage+'').text(Number(allpric)-Number(data.result.data[i][0].orderPrice))
                                     }
//                                  allpric==data.result.data[i][0].orderPrice
								}
//								alert("你好");
							}
						}
						//	订单页面宽度

					         var mine_infororder = 1030*.97*.45+'px';
					         $('.mine_infors').css('width',mine_infororder);
						
						     var sign_p = 1030*.97*.125+'px';
					         $('.sign_ps').css('width',sign_p);
					         
					         var times = 1030*.97*.125+'px';
					         $('.timess').css('width',times);
						
						     var all_pri = 1030*.97*.125+'px';
					         $('.all_pris').css('width',all_pri);
					},
					error: function(e) {
						console.log(JSON.stringify(e) + '<<<<错误');
												
					}
				})
		}
		}
		
				
			
			
		
		
		
		
		
		
		
//		             orderList(1);
					function orderList(){
						$('#page').css('display','block');
//				订单接口
//               alert(localStorage.status);
				$.ajax({
					//					url: ur + 'mobilemember/frontOrder/orderlist',
					url: ur + '/mobilemember/frontOrder/orderlist',
					type: 'post',
					dataType: 'json',
					headers: {
						'X-Token': localStorage.wyshoptoken,
					},
					data: {
						'orderVO.status': localStorage.status,
						'numPerPage':5,
						'pageNum':1,
						'pageRequest':1
						//								'status':status
					},
					success: function(data){
						
                         if(data.result.meta.code == 201){
                         	$('.order_all').html('');
                         	var divimg = $('<div style="margin:5rem auto 0;text-align: center;"><p style="color:#999999;font-size: 18px;">没有符合条件商品	</p></div>');
                         	$('.order_all').append(divimg);
                         	$('#page').css('display','none');
//                       	$('.order_con').css('display','none');
//                       	$('.classpage').css('display','none');
                         }else if(data.result.meta.code==200){
							sessionStorage.wyShopPase = data.paginator.totalCount;
							classpage();
		             }
					},
					error: function(e) {
						console.log(JSON.stringify(e) + '<<<<错误');
												
					}
				})
			}
		     
		     
		     
		     
		     //获取退货列表
		     function tuihuo() {
					$.ajax({
						url: ur + '/mobilemember/frontmember/findRefundGoodsList',
						type: 'POST',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						dataType: 'json',
						//					退货进行中
						data: {
							"noStatesStr": localStorage.noStatesStr,
							"refundType": localStorage.refundType
						},
						success: function(data) {
							
							
							var img = $('<div class="noimg">您还没有此类型订单</div>');
							//						非空

							//							填充
							if(localStorage.noStatesStr == '5') {
								if(data.result.meta.code == '202') {
									$('.mbtuihuo').append(img);
//									$('.mbackging_title').css('display','none');
								}
								if(data.result.meta.code == '200'){
									
									for(var i = 0; i < data.result.data.refundgoodsVOList.length; i++) {
										var signorpri = 0;
										var pri = 0;
										var n = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs.length;
										for(var j = 0; j < n; j++) {
											pri = pri + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price;
											localStorage.price = pri;
										}
										
										var div = $('<div class="order_dan">'+
																'<div class="order_zt"><span class="order_date">' + data.result.data.refundgoodsVOList[i].createTime + '</span><span class="order_num">订单号：<span class="order_number">' + data.result.data.refundgoodsVOList[i].orderNum + '</span></span><span class="order_typesi">退货进行中</span></div>'+
																'<div class="order_danall minethg'+i+'">'+
//																	'<div class="order_consig">'+
//																		'<div class="mine_infors">'+
//																			'<span></span>'+
//																			'<div class="goods_shux">'+
//																				'<p class="goods_name">阿斯顿阿斯顿发送撒旦法师打发斯蒂芬发士大夫撒旦飞洒地方撒旦 </p>'+
//																				'<p class="goods_type">类型：红色罐装</p>'+
//																			'</div>'+
//																		'</div>'+
//																		'<div class="sign_ps">￥<span>120.00</span></div>'+
//																		'<div class="timess">' + n + '</div>'+
//																		'<div class="all_pris">￥<span>' + localStorage.price + '</span></div>'+
//																	'</div>'+
																'</div>'+
																'<div class="operes">'+
																	'<div class="tuikallp">退款总金额</div>'+
																	'<div class="tuikaallpd">￥<span class="tuikaallpd'+i+'"></span></div>'+
																'</div>'+
														    '</div>');
										
										$('.mbtuihuo').append(div);
										
										for(var j = 0; j < n; j++) {
											var b = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].mainIng;
											
											var m = b.indexOf(',');
											if(m != '-1') {
												var mainImg = b.substring(0, m);
											} else {
												mainImg = b;
											}
											
											function whobiger(a,b){
												var biger;
												if(a==b){
													biger = a;
													
												}else if(a>b){
													biger = b;
												}else if(b>a){
													biger = a;
												}
												return biger;
											}
											var aa = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].newPrice;
											var bb = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price;
											var bigerp = whobiger(aa,bb);
											
											
											var thallprice = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount*bigerp;
											signorpri = signorpri + thallprice;
											$('.tuikaallpd'+i+'').text(signorpri);
											var div2 = $('<div class="order_consig">'+
																		'<div class="mine_infors">'+
																			'<span style="background-image: url(' + picur + mainImg + ');background-position:center;background-repeat:no-repeat;background-size:cover;"></span>'+
																			'<div class="goods_shux">'+
																				'<p class="goods_name">' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].shortname + ' </p>'+
//																				'<p class="goods_type">类型：红色罐装</p>'+
																			'</div>'+
																		'</div>'+
																		'<div class="sign_ps">￥<span>' + bigerp + '</span></div>'+
																		'<div class="timess">' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount + '</div>'+
																		'<div class="all_pris">￥<span>' + thallprice + '</span></div>'+
																	'</div>');
											
											$('.minethg' + i ).append(div2);
										}
									}

								}
							} else {
								if(data.result.meta.code == '202') {
									$('.mbtuihuoed').append(img);
//									$('.mbackging_title').css('display','none');
								}
								if(data.result.meta.code == '200') {
									
									for(var i = 0; i < data.result.data.refundgoodsVOList.length; i++) {
										var signorpried = 0;
										var pri = 0;
										var n = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs.length;
										for(var j = 0; j < n; j++) {
											pri = pri + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price;
											localStorage.price = pri;
										}
										var div = $('<div class="order_dan">'+
																'<div class="order_zt"><span class="order_date">' + data.result.data.refundgoodsVOList[i].createTime + '</span><span class="order_num">订单号：<span class="order_number">' + data.result.data.refundgoodsVOList[i].orderNum + '</span></span><span class="order_typesi">退货已完成</span></div>'+
																'<div class="order_danall minethd'+i+'">'+
//																	'<div class="order_consig">'+
//																		'<div class="mine_infors">'+
//																			'<span></span>'+
//																			'<div class="goods_shux">'+
//																				'<p class="goods_name">阿斯顿阿斯顿发送撒旦法师打发斯蒂芬发士大夫撒旦飞洒地方撒旦 </p>'+
//																				'<p class="goods_type">类型：红色罐装</p>'+
//																			'</div>'+
//																		'</div>'+
//																		'<div class="sign_ps">￥<span>120.00</span></div>'+
//																		'<div class="timess">' + n + '</div>'+
//																		'<div class="all_pris">￥<span>' + localStorage.price + '</span></div>'+
//																	'</div>'+
																'</div>'+
																'<div class="operes">'+
																	'<div class="tuihuoap">退款总金额</div>'+
																	'<div class="tuihuopri">￥<span class="tuihuopri'+i+'"></span></div>'+
																'</div>'+
														    '</div>');
										
										
										$('.mbtuihuoed').append(div);
										
										for(var j = 0; j < n; j++) {
											var b = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].mainIng;
											console.log(b.indexOf(',') + '逗号索引值');
											var m = b.indexOf(',');
											if(m != '-1') {
												var mainImg = b.substring(0, m);
											} else {
												mainImg = b;
											}
											//									console.log(data.result.data.refundgoodsVOList[0].refundGoodsproductVOs[j].price + '价格');
											//									console.log(data.result.data.refundgoodsVOList[0].refundGoodsproductVOs[0].price)
											
											
											
											function whobiger(a,b){
												var biger;
												if(a==b){
													biger = a;
													
												}else if(a>b){
													biger = b;
												}else if(b>a){
													biger = a;
												}
												return biger;
											}
											var aad = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].newPrice;
											var bbd = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price;
											var bigerpd = whobiger(aad,bbd);
											
											
											var thallpriced = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount*bigerpd;
//										alert(typeof(data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount));
//										alert(typeof(bigerp));
											signorpried = thallpriced + signorpried;
											$('.tuihuopri'+i+'').text(signorpried);
											var div2 = $('<div class="order_consig">'+
																		'<div class="mine_infors">'+
																			'<span style="background-image: url(' + picur + mainImg + ');background-position:center;background-repeat:no-repeat;background-size:cover;"></span>'+
																			'<div class="goods_shux">'+
																				'<p class="goods_name">' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].shortname + ' </p>'+
//																				'<p class="goods_type">类型：红色罐装</p>'+
																			'</div>'+
																		'</div>'+
																		'<div class="sign_ps">￥<span>' + bigerpd + '</span></div>'+
																		'<div class="timess">' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount + '</div>'+
																		'<div class="all_pris">￥<span>' + thallpriced + '</span></div>'+
																	'</div>');
											$('.minethd'+i).append(div2);
										}
									}

								}
							}
							
							 var mine_infororder = 1030*.97*.45+'px';
					         $('.mine_infors').css('width',mine_infororder);
						
						     var sign_p = 1030*.97*.125+'px';
					         $('.sign_ps').css('width',sign_p);
					         
					         var times = 1030*.97*.125+'px';
					         $('.timess').css('width',times);
						
						     var all_pri = 1030*.97*.125+'px';
					         $('.all_pris').css('width',all_pri);
							
							

						},
						error: function(e) {
							console.log(JSON.stringify(e) + '错误')
						}
					})
				}
		     
		     
		     
		     
		     
		     
		     
		     
		     
		     
		     
		     
		     
		     //获取退款列表
		     function tuikuan(){
					$.ajax({
						url: ur + '/mobilemember/frontmember/findOrderRefundList',
						type: 'POST',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						dataType: 'json',
						//					退货进行中
						data: {
							'refunded': localStorage.refunded
						},
						success: function(data) {
							
							
							var img = $('<div class="noimg">您还没有此类型订单</div>');
							if(localStorage.refunded == '8') {
								if(data.result.meta.code == '200') {
									for(var i = 0; i < data.result.data.orderRefundVOList.length; i++) {
//										var div = $('<div class="main">' +
//											'<p><span>店铺名称：魏远商城</span><span class="zt">' + data.result.data.orderRefundVOList[i].statusName + '</span></p>' +
//											'<p>订单编号: ' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</p>' +
//											'<p class="b1"><span>退款原由: </span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
//											'<p class="b2"> <span>退款金额:</span><span>￥  ' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//											'<p class="b3"><span>' + data.result.data.orderRefundVOList[i].applyTime + '</span></p>' +
//											'</div>'
//										);

                               
                               var b = data.result.data.orderRefundVOList[i].orderVO.orderProductVOs[0].skuProductVO.productVO.mainImg;;
									console.log(b.indexOf(',') + '逗号索引值');
									var m = b.indexOf(',');
									if(m != '-1') {
										var mainImg = b.substring(0, m);
									} else {
										mainImg = b;
									}

 
//									var backkimg = data.result.data.orderRefundVOList[i].orderVO.orderProductVOs[0].skuProductVO.productVO.mainImg;
								var div = $('<div class="order_dan">'+
									'<div class="order_zt"><span class="order_date">' + data.result.data.orderRefundVOList[i].applyTime + '</span><span class="order_num">订单号：<span class="order_number">' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</span></span><span class="order_typesi">' + data.result.data.orderRefundVOList[i].statusName + '</span></div>'+
									'<div  class="mineb_danall">'+
										'<div class="order_consig">'+
										    
										    '<div class="minemb_infors">'+
												'<span style="background-image: url(' + picur + mainImg + ');background-position:center;background-repeat:no-repeat;background-size:cover;"></span>'+
												'<div class="goods_shux">'+
													'<p class="goods_name">' + data.result.data.orderRefundVOList[i].orderVO.orderName + ' </p>'+
//																				'<p class="goods_type">类型：红色罐装</p>'+
												'</div>'+
											'</div>'+
										    
//											'<div class="minemb_infors">'+
//												'<span></span>'+
//												'<div class="tuikinfo">'+
//													'<p class="goods_name">' + data.result.data.orderRefundVOList[i].orderVO.orderName + ' </p>'+
//													'<p class="goods_type">类型：红色罐装</p>'+
//												'</div>'+
//											'</div>'+
											'<div class="mpsign_ps"><span>' + data.result.data.orderRefundVOList[i].content + '</span></div>'+
											
										'</div>'+
									'</div>'+
									'<div class="mboperes">'+
										'<div class="">退款金额</div>'+
										'<div class="tuimoneying">￥<span>' + data.result.data.orderRefundVOList[i].amount + '</span></div>'+
									'</div>'+
							    '</div>');
							    $('.btuikuang').append(div);
									}
									
								}
								if(data.result.meta.code == '202') {
									$('.btuikuang').append(img);
//									$('.mbackging_title').css('display','none');
								}
							} else if(localStorage.refunded == '7'){
								if(data.result.meta.code == '200') {
									
									for(var i = 0; i < data.result.data.orderRefundVOList.length; i++) {
										
											var b = data.result.data.orderRefundVOList[i].orderVO.orderProductVOs[0].skuProductVO.productVO.mainImg;
											console.log(b.indexOf(',') + '逗号索引值');
											var m = b.indexOf(',');
											if(m != '-1') {
												var mainImg = b.substring(0, m);
											} else {
												mainImg = b;
										}
										var div = $('<div class="order_dan">'+
									'<div class="order_zt"><span class="order_date">' + data.result.data.orderRefundVOList[i].applyTime + '</span><span class="order_num">订单号：<span class="order_number">' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</span></span><span class="order_typesi">' + data.result.data.orderRefundVOList[i].statusName + '</span></div>'+
									'<div  class="mineb_danall">'+
										'<div class="order_consig">'+
											'<div class="minemb_infors">'+
												'<span  style="background-image: url(' + picur + mainImg + ');background-position:center;background-repeat:no-repeat;background-size:cover;"></span>'+
												'<div class="tuikinfo">'+
													'<p class="goods_name">' + data.result.data.orderRefundVOList[i].orderVO.orderName + ' </p>'+
//													'<p class="goods_type">类型：红色罐装</p>'+
												'</div>'+
											'</div>'+
											'<div class="mpsign_ps"><span>' + data.result.data.orderRefundVOList[i].content + '</span></div>'+
											
										'</div>'+
									'</div>'+
									'<div class="mboperes">'+
										'<div class="">退款金额</div>'+
										'<div class="tuimoneyed">￥<span>' + data.result.data.orderRefundVOList[i].amount + '</span></div>'+
									'</div>'+
							    '</div>'
										);
										$('.btuikuanged').append(div);
									}
									
							}if(data.result.meta.code == '202') {
									$('.btuikuanged').append(img);
//									$('.mbackging_title').css('display','none');
								}
							}

                            var mine_infororder = 1030*.97*.45+'px';
					         $('.minemb_infors').css('width',mine_infororder);
						
						     var sign_p = 1030*.97*.29+'px';
					         $('.mpsign_ps').css('width',sign_p);
					         
//					         var times = 1030*.75*.125+'px';
//					         $('.timess').css('width',times);
//						
//						     var all_pri = 1030*.97*.125+'px';
//					         $('.all_pris').css('width',all_pri);
//


						},
						error: function(e) {
							console.log(JSON.stringify(e) + '错误')
						}
					})
				}
		     
		     
		
		
		/*分页逻辑*/
		
		function classpagezhangdan(){
//			alert(allpage);	
            var p = new Page('page');
			//总记录数
			p.recordCount = sessionStorage.wyShopPase;
			//分页按扭数
			p.numericButtonCount = 4;
			//每页记录数YW
			p.pageSize = 6;
			//当点击分页时触发此事件。 一些外加的效果可以放在此处， 如加载数据
			p.addListener('pageChanged', function() {
//				alert('第' + p.pageIndex + '页');
				p.render();
				$('.conpain_all').html('');
				pagelistzhang();
			});
			p.initialize();

		      function pagelistzhang(){
				
			    $.ajax({
						url: ur + '/mobilemember/frontmember/getEmployeesCoupon',
						type: 'POST',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						dataType: 'json',
						data: {
							"numPerPage":p.pageSize,
							"pageNum":p.pageIndex,
							"pageRequest":1
						},
						success:function(data){
							console.log(data);
							if(data.result.meta.code==200){
								
								if(data.result.data.emplogList.length==0){
									$('#page').css('display','none');
									var divimg = $('<div style="margin:5rem auto 0;text-align: center;"><p style="color:#999999;font-size: 18px;">您目前还没有福利券</p></div>');
                         	         $('.conpain_all').append(divimg);
								}else{
									pageindeqy = data.paginator.pageIndex;
								
	//							if(data.paginator.totalCount==$('.my-coupon-content>div').length){
	//								
	//							};
								 for(var i=0;i<data.result.data.emplogList.length;i++){
									var time = data.result.data.emplogList[i].creageTime;
									var tim= time.substring(0,10);
									
									
									var div = ('<div class="conpain_sing">'+
									'<div class="c_all_infor">'+
										'<div class="price_all_infor">'+
											'<span>￥</span>'+
											'<span>'+data.result.data.emplogList[i].balance+'</span>'+
											'<span>元</span>'+
										'</div>'+
										'<p>已经到账余额<span class="c_getprice">'+data.result.data.emplogList[i].balance+'</span>元</p>'+
										'<span>'+tim+'</span>'+
									'</div>'+
								'</div>');
									
									
									$('.conpain_all').append(div);
								}
							}
//							alert($('.my-coupon-content>div').length);

//							if(data.paginator.totalCount==$('.my-coupon-content>div').length){
//								$('.coumore').off();
//								$('.coumore').text('已无更多');
//							};
						   }
						}
					})

				}
		      }
		      
		      
		      function listzhang(){
				 $('#page').css('display','block');
			    $.ajax({
						url: ur + '/mobilemember/frontmember/getEmployeesCoupon',
						type: 'POST',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						dataType: 'json',
						data: {
							"numPerPage":1,
							"pageNum":1,
							"pageRequest":1
						},
						success:function(data){
							console.log(data);
							if(data.result.meta.code==200){
								sessionStorage.wyShopPase = data.paginator.totalCount;
							    classpagezhangdan();
						   }
						}
					})

				}
		      
		      
		      /*获取余额*/
			function getmoney() {

				$.ajax({
					url:ur+'/mobilemember/frontmember/accountPayList',
					type: 'GET',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					data: {
					}
				})
						.done(function(data) {
							console.log(data);
                            if(data.result.meta.code==200){
							$('.mine_balalancep').text(Math.round(data.balance * 100) / 100);
							}
						})

			}
		
		
		
		/*获取账单明细*/
		
		function classpagebill(){
//			alert(allpage);	
            var p = new Page('page');
			//总记录数
			p.recordCount = sessionStorage.wyShopPase;
			//分页按扭数
//			alert(p.recordCount);
			p.numericButtonCount = 4;
			//每页记录数YW
			p.pageSize = 10;
			//当点击分页时触发此事件。 一些外加的效果可以放在此处， 如加载数据
			p.addListener('pageChanged', function() {
//				alert('第' + p.pageIndex + '页');
				p.render();
				$('.my_bill_con').html('');
				pagebill();
			});
			p.initialize();

		
		
		//获取我的账单
		function pagebill() {
				$.ajax({
					url: ur + '/mobilemember/frontmember/accountPayList',
					type: 'POST',
					headers: {
						"X-Token": localStorage.wyshoptoken,
					},
					dataType: 'json',
					data: {
						'numPerPage': p.pageSize,
						'pageNum': p.pageIndex,
						'pageRequest': '1'
					},
					success: function(data) {
						console.log(JSON.stringify(data))
						if(data.result.meta.code == 200) {
							
							

							for(var i = 0; i < data.transactionVOs.length; i++) {
								var d = data.transactionVOs[i].txnDate.substring(0, 10);
								var t = data.transactionVOs[i].txnTime.substring(11, 19);
								var div = $('<div class="my_bill_con_dan">'+
										'<div><span>'+d+'<br/>'+t+'</span></div>'+
										'<div><span>' + data.transactionVOs[i].orderName + '</span></div>'+
										'<div><span>' + data.transactionVOs[i].goodsPrice + '</span></div>'+
										'<div><span>' + data.transactionVOs[i].payName + '</span></div>'+
										'<div><span>' + data.transactionVOs[i].goodsCode + '</span></div>'+
									'</div>');
								$('.my_bill_con').append(div);
							}
						}
//						if (data.result.meta.code == 201){
//							var img = $('<p style="text-align: center;">没有更多信息...</p>');
//									$('#mui-table-view').append(img);
//						}
					},
					error: function(e) {
						console.log(e);
					}
				})
			}
		
		}
		
		
		function bill() {
			$('#page').css('display','block');
				$.ajax({
					url: ur + '/mobilemember/frontmember/accountPayList',
					type: 'POST',
					headers: {
						"X-Token": localStorage.wyshoptoken,
					},
					dataType: 'json',
					data: {
						'numPerPage': 1,
						'pageNum': 1,
						'pageRequest': '1'
					},
					success: function(data) {
						console.log(JSON.stringify(data))
						if(data.result.meta.code == 200) {
						sessionStorage.wyShopPase = data.paginator.totalCount;
						classpagebill();
						}
//						if (data.result.meta.code == 201){
//							var img = $('<p style="text-align: center;">没有更多信息...</p>');
//									$('#mui-table-view').append(img);
//						}
					},
					error: function(e) {
						console.log(e);
					}
				})
			}
		
		   /*查看我的投诉建议*/
			function getmyjy(){
//				alert(11);
				$('#mine_ts').html('');
				
				$.ajax({
					type:"post",
					url:ur+'/mobilemember/frontmember/getSuggestion',
					async:true,
					headers:{
						'X-Token':localStorage.wyshoptoken
					},
					success:function(data){
						console.log(data);
						if(data.result.meta.code==200){
							console.log(data.result.data.length);
							for(var i=0;i<data.result.data.length;i++){
//								var divd = ('<div class="main1" id="'+data.result.data[i].sugId+'" lid="'+i+'">'+
//									'<p class="main3"><span>对象：</span><span class="type'+i+'">其他</span></p>'+
//									'<p><span>涉及订单号：</span><span>'+data.result.data[i].sugOrderNum+'</span></p>'+
//									'<p class="main2"><span>投诉内容</span><span class="de">查看内容详情</span><span class="de"><img src="img/turn-right.png"/></span></p>'+
//								'</div>');
								var divd = ('<div class="cpmplain_type_con2_dan">'+
										'<div class="cpmplain_info">'+
											'<div class="cpmplain_info_div"></div>'+
											'<div class="cpmplain_dinfo">'+
												'<span>对象：<span class="type'+i+'">其他</span></span>'+
												'<span>涉及订单：<span>'+data.result.data[i].sugOrderNum+'</span></span>'+
												'<span>提交时间：<span>'+data.result.data[i].sugCreateDate.replace('T','  ')+'</span></span>'+
												'<span class="cpmplain_dinfo_more">展开</span>'+
											'</div>'+
										'</div>'+
										'<div class="cpmplain_info_details" style="display: none;">'+
											'<div><span class="cpmplain_info_details_neo">内容：</span><span class="cpmplain_info_details_text">'+data.result.data[i].sugContent+'</span></div>'+
										'</div>'+
									'</div>');
								$('.cpmplain_type_con2').append(divd);
								if(data.result.data[i].sugSort==1){
								    $('.type'+i+'').text('订单问题');
							    }else if(data.result.data[i].sugSort==2){
							    	$('.type'+i+'').text('物流问题');
							    }else if(data.result.data[i].sugSort==3){
							    	$('.type'+i+'').text('客户问题');
							    }else if(data.result.data[i].sugSort==4){
							    	$('.type'+i+'').text('商品质量');
							    }else if(data.result.data[i].sugSort==5){
							    	$('.type'+i+'').text('价格问题');
							    }else if(data.result.data[i].sugSort==6){
							    	$('.type'+i+'').text('网站功能');
							    }else if(data.result.data[i].sugSort==7){
							    	$('.type'+i+'').text('建议');
							    }else if(data.result.data[i].sugSort==8){
							    	$('.type'+i+'').text('其他');
							    }
							}			
							
						}
					},
					error:function(){
						
					}
				});
			}
		
		/*提交投诉建议*/
		$('.commit_complain').on('click',function(){
			
				if(!$('.select_type_comliain>span>span').hasClass('borderselected')){
					$('.mine-tipsselect').css('visibility','visible');
				}else if($('.about_order_number>input').val()==''){
					$('.mine-tipsordernum').css('visibility','visible');
				}else if($('.com_context>textarea').val()==''){
					$('.mine-tipscont').css('visibility','visible');
				}else{
				    submitjianyi();
				}
			});
			
			/*提交投诉建议接口*/
			function submitjianyi(){		
				
				$.ajax({
					type:"post",
					url:ur+'/mobilemember/frontmember/saveSuggestionByAdd',
					async:true,
					headers:{
						'X-Token':localStorage.wyshoptoken
					},
					data:{
						'csuggestionVO.sugContent':$('.com_context>textarea').val(),
						'csuggestionVO.sugOrderNum':$('.about_order_number>input').val(),
						'csuggestionVO.sugSort':sessionStorage.wyshopwhtype
					},
					success:function(data){
						console.log(data);
						
						if(data.result.meta.code==200){
							$('.mine_complainsuccess').css('display','block');
							$('.com_context>textarea').val('');
							$('.about_order_number>input').val('');
							$('.tousucon').val('');		
							mine_complain();
						}else{
							alert(data.result.meta.message);
						}
					},
					error:function(){
					
					}
				});
			}
			
			//提交成功跳转
			function mine_complain(){
					setTimeout(function(){
						$('.mine_complainsuccess').css('display','none');
						$('.cpmplain_type_con>div').eq(1).css('display','block');
						$('.cpmplain_type_con>div').eq(1).siblings().css('display','none');
						$('.cpmplain_type>span').eq(1).css({"color":"#ff5350","border-bottom":"2px solid #ff5350"});
						$('.cpmplain_type>span').eq(1).siblings().css({"color":"black","border-bottom":"none"});
						},3000);
				}
			
			
			$('.mine_complai_cancel').on('click',function(){
				$('.mine_complainsuccess').css('display','none');
			});
			
			
			
			    //展示收货地址
				function showlist(){
					
				$.ajax({
					type: 'post',
					url: ur + '/mobilemember/frontmember/listAddress',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},					
					data: {},
					dataType: 'json',
					success: function(data) {
 						
						if(data.result.meta.code==200){
							 
						for(var i = 0; i < data.result.data.length; i++) {	
							if(data.result.data[i].isDefault==1){
								var div = $('<div class="my_address_sing"  id="' + data.result.data[i].id + '">'+
								'<div></div>'+
								'<div>'+
									'<div class="mine_deltte_oderd">'+
										'<span class="delete_address"></span>'+
									'</div>'+
									'<div>收货人：<span class="address_name">' + data.result.data[i].reciver + '</span></div>'+
									'<div>联系电话：<span class="addphonenun">' + data.result.data[i].phone + '</span></div>'+
									'<div>所在地区：<span class="adddetaarea">' + data.result.data[i].area + '</span></div>'+
									'<div>详细地址：<span class="addetails">' + data.result.data[i].detail + '</span><span class="editer_address">编辑</span><span mrdz = "'+data.result.data[i].isDefault+'" class="setmo defomo">默认地址</span></div>'+
								'</div>'+
							'</div>');
                               $('.address_all_con').append(div);
							}
						}
						
						for(var i = 0; i < data.result.data.length; i++) {
//							var div = $('<div class="card" th="'+i+'">' +
//								'<div class="card-content">' +
//								'<div class="card-content-inner">' +
//								'<p class="user-info"><span class="iconfont icon-iconfontlianxiren01"></span>' +
//								'<span>' + data.result.data[i].reciver + '</span><span class="iconfont icon-shouji2">' +
//								'</span><span>' + data.result.data[i].phone + '</span></p>' +
//								'<p class="user-addr"><span></span><span>' + data.result.data[i].city + '</span><span>' + data.result.data[i].area + '</span>' +
//								'<span>' + data.result.data[i].detail + '</span></p></div></div>' +
//								'<div class="card-footer"><span class="pull-left" id=' + 'defau' + data.result.data[i].isDefault + ' ida="' + data.result.data[i].id + '">设置默认</span>' +
//								'<span class="pull-right"><a class="externalxg"><i class="iconfont icon-bianji"></i>编辑</a>' +
//								'<span class="det" id=' + data.result.data[i].id + '><i class="iconfont icon-lajixiang"></i>删除</span></span></div></div>')
							
							var div = $('<div class="my_address_sing defo'+i+'" id="' + data.result.data[i].id + '" >'+
								'<div></div>'+
								'<div>'+
									'<div class="mine_deltte_oderd">'+
										'<span class="delete_address"></span>'+
									'</div>'+
									'<div>收货人：<span class="address_name">' + data.result.data[i].reciver + '</span></div>'+
									'<div>联系电话：<span class="addphonenun">' + data.result.data[i].phone + '</span></div>'+
									'<div>所在地区：<span class="adddetaarea">' + data.result.data[i].area + '</span></div>'+
									'<div>详细地址：<span class="addetails">' + data.result.data[i].detail + '</span><span class="editer_address">编辑</span><span mrdz = "'+data.result.data[i].isDefault+'" class="setmo">设为默认</span></div>'+
								'</div>'+
							'</div>');
							$('.address_all_con').append(div);
                              if(data.result.data[i].isDefault==1){
                              	$('.defo'+i+'').css('display','none');
                              }
							
						}
                      }else if(data.result.meta.code==201){
                      	  var divimg = ('<div style="margin:5rem auto 0;text-align: center;"><img style="width:35%;" src="img/nogood.png"><p style="color:#6a6a6a;font-size: .8rem;">您暂时还没有收货地址哦</p></div>');
                      	  $('.content').append(divimg);
                      	  
                      }
					},
					error: function(data) {
					
						console.log(data);
					}
				});
			}
				
				/*删除收货地址*/
				var deleadd = '';
			$('.address_all_con').on('click','.delete_address',function(){
				$('.ifdeleorder').css('display','block');
				 deleadd = $(this).parents('.my_address_sing');
				sessionStorage.wyshopdeleadd = $(this).parents('.my_address_sing').attr('id');

			})
				
			/*删除地址*/
			$('.ifdeleoyes').on('click',function(){
				var thisdeadd = $(this);
				$.ajax({
						url: ur + '/mobilemember/frontmember/deleteAddress',
						type: 'post',
						dataType: 'json',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						data: {
							"id":sessionStorage.wyshopdeleadd ,
							/*"id": '40288051594f367a015963128b240033',*/
							"size": '0',
						},
						success: function(data) {
                             if(data.result.meta.code==200){

                            thisdeadd.parents('.ifdeleorder').css('display','none');
							console.log(data);
							deleadd.css('display','none');
							if(data == '操作成功') {
								mui.toast('删除成功');
							} else {
								/*plus.nativeUI.closeWaiting();*/
							}
							}
						}
						})
				
			});
			
			/*取消删除地址*/
			$('.delete1-i').on('click',function(){
				$(this).parents('.ifdeleorder').css('display','none');
			});
			
			$('.delete1-n').on('click',function(){
				$(this).parents('.ifdeleorder').css('display','none');
			});
			
			/*设置为默认地址*/
			$('.address_all_con').on('click','.setmo',function(){
				var smoren = $(this).parents('.my_address_sing').attr('id');
//				$(this).css({'background-color':'#FF5350','color':'white'});
//				$(this).parents('.my_address_sing').siblings('.setmo').css({'color':'#ff5350','background-color':'white'});
//				 alert(smoren)
				$.ajax({
					url: ur + '/mobilemember/frontmember/updateAddressById',
					type: 'post',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					data: {
						"addressVO.id": smoren,
						"addressVO.isDefault": 1,
					},
					success: function(data) {
						console.log(data);
						console.log(data.result.meta.code);
						if(data.result.meta.code == 200) {
                            
//							mui.toast('设置默认地址成功');
//							divdan.css({ 'color': '#fff', 'background-color': '#e9af29', 'border': 'none' });
//							divdan.text('默认地址');
//							divdano.css({ 'color': '#666', 'background-color': 'transparent', 'border': '1px solid #999' });
//							divdano.text('设置默认');
                         $('.address_all_con').html('');
                            showlist();
						   
							/*divdano.css({'color': '#666','border': '1px solid #999'});*/
						} else {
							/*plus.nativeUI.closeWaiting();*/
						}
					},
					error:function(data){
						mui.toast("系统错误");
					}
				})
				
				
			})
			var tapwhere = '';
			//新建收货地址弹窗
			$('.creat_address').on('click',function(){
				$('.crnameno').css('visibility','hidden');
				$('.crphoneno').css('visibility','hidden');
				$('.crquyuno').css('visibility','hidden');
				$('.crdeno').css('visibility','hidden');
				$('.creat_address_info').find('input').val('');
				$('.creat_address_info').find('textarea').val('');
				$('.creat_address_info').find('select').val('');
				$('.creat_address_d').css('display','block');
		//		alert($(this).parents('body'));
		//		$(this).parents('body').css({"height":h,"overflow": "hidden"});
		//		$(this).parents('html').css({"height":h,"overflow": "hidden"});
		        $('#city10>option').not(":first").remove(); 
		        $('#district10>option').not(":first").remove(); 
		        $('#street10>option').not(":first").remove(); 
				$('.selectStreet').css('display','none');
		        tapwhere = 1;
		        selAddress(0);
			})
			
			function selAddress(parentNo){			
				$.ajax({
						type: 'post',
						url: ur + '/mobile/getAddress',
						headers: {
							"X-Token": localStorage.token
						},
						data: {
							"jdaddressVO.parentId": parentNo,
						},
						dataType: 'json',
						success: function(data) {
							console.log(data);
							if(data.result.meta.code == 200) {
                                 
                                 for(var i=0;i<data.result.data.length;i++){
                                 	  var spanh = $('<option value="'+data.result.data[i].name+'" id='+data.result.data[i].id+'>'+data.result.data[i].name+'</option>');
                                 	  if(tapwhere==1){
                                 	  	$("#province10").append(spanh);
                                 	  }else if(tapwhere==2){
                                 	  	$("#city10").append(spanh);
                                 	  }else if(tapwhere==3){
                                 	  	$("#district10").append(spanh);
                                 	  }else if(tapwhere==4){
                                 	  	$("#street10").append(spanh);
                                 	  }
                                 	  
                                 }
							} else if(data.result.meta.code == 301) {

							}
						},
						error: function(data) {
							console.log(data);
							//						plus.nativeUI.closeWaiting();
						}
					});
			}
			
			function selAddresslast(parentNo){
//				alert(parentNo);
				$.ajax({
						type: 'post',
						url: ur + '/mobile/getAddress',
						headers: {
							"X-Token": localStorage.token
						},
						data: {
							"jdaddressVO.parentId": parentNo,
						},
						dataType: 'json',
						success: function(data) {
							console.log(data);
							if(data.result.meta.code == 200) {
                                 if(data.result.data.length>0){
                                 	 $('.selectStreet').css('display','block');
                                 	 for(var i=0;i<data.result.data.length;i++){
	                                 	  var spanh = $('<option value="'+data.result.data[i].name+'" id='+data.result.data[i].id+'>'+data.result.data[i].name+'</option>');
	                                 	  
	                                 	  	$("#street10").append(spanh);
	                                 	  
                                 	  
                                     }
                                 }
                                 
							} else if(data.result.meta.code == 301) {

							}
						},
						error: function(data) {
							console.log(data);
							//						plus.nativeUI.closeWaiting();
						}
					});
			}
			
			
			$('#province10').change(function(){
				$('#city10>option').not(":first").remove(); 
				tapwhere = 2;
		        selAddress($(this).find("option:checked").attr("id"));
			})
			
			$('#city10').change(function(){
				$('#district10>option').not(":first").remove(); 
				tapwhere = 3;
		        selAddress($(this).find("option:checked").attr("id"));
			})
			
			$('#district10').change(function(){
				$('#street10>option').not(":first").remove(); 
				$('.selectStreet').css('display','none');
				tapwhere = 4;
		        selAddresslast($(this).find("option:checked").attr("id"));
			})
			
			
			var defu ='';
			//编辑收货地址弹窗
			$('.address_all_con').on('click','.editer_address',function(){
				tapwhere = 1;
		        bselAddress(0);
				var b =$(this).parents('.my_address_sing').index();
				var a= $(this).parents('.my_address_sing').find('.setmo').eq(b).attr('mrdz');
				if(a == 1){
					defu=1;
					$('.mo_address').css({'background-color':'#FF5350','color':'white'});
				}else{
					defu=0;
					$('.mo_address').css({'color':'#ff5350','background-color':'white'})
				}
				$('.editor_address_d').css('display','block');
				sessionStorage.wyshopeditorw = $(this).parents('.my_address_sing').attr('id');
				$('.editor_name_in').val($(this).parents('.my_address_sing').find('.address_name').text());
				$('.editor_phone_in').val($(this).parents('.my_address_sing').find('.addphonenun').text());
				$('.editer_de').val($(this).parents('.my_address_sing').find('.addetails').text());
				var adrdetails =  $(this).parents('.my_address_sing').find('.adddetaarea').text();
				
//				var adrdetailsarr = adrdetails.split(" ");
//				alert(adrdetailsarr[2]);
//				$('.editer_shen').text(adrdetailsarr[0]);
//				$('.editer_shi').text(adrdetailsarr[1]);
//				$('.editer_qu').text(adrdetailsarr[2]);
//				  $('#distpicker4').distpicker({
//				    province: $('.editer_shen').text(adrdetailsarr[0]),
//				    city: $('.editer_shi').text(adrdetailsarr[1]),
//				    district: $('.editer_qu').text(adrdetailsarr[2])
//				  });
			});
			
			
			$('#bprovince10').change(function(){
				$('#bcity10>option').not(":first").remove(); 
				tapwhere = 2;
		        bselAddress($(this).find("option:checked").attr("id"));
			})
			
			$('#bcity10').change(function(){
				$('#bdistrict10>option').not(":first").remove(); 
				tapwhere = 3;
		        bselAddress($(this).find("option:checked").attr("id"));
			})
			
			$('#bdistrict10').change(function(){
				$('#bstreet10>option').not(":first").remove(); 
				$('.bselectStreet').css('display','none');
				tapwhere = 4;
		        bselAddresslast($(this).find("option:checked").attr("id"));
			})
			
			
			function bselAddress(parentNo){			
				$.ajax({
						type: 'post',
						url: ur + '/mobile/getAddress',
						headers: {
							"X-Token": localStorage.token
						},
						data: {
							"jdaddressVO.parentId": parentNo,
						},
						dataType: 'json',
						success: function(data) {
							console.log(data);
							if(data.result.meta.code == 200) {
                                 
                                 for(var i=0;i<data.result.data.length;i++){
                                 	  var spanh = $('<option value="'+data.result.data[i].name+'" id='+data.result.data[i].id+'>'+data.result.data[i].name+'</option>');
                                 	  if(tapwhere==1){
                                 	  	$("#bprovince10").append(spanh);
                                 	  }else if(tapwhere==2){
                                 	  	$("#bcity10").append(spanh);
                                 	  }else if(tapwhere==3){
                                 	  	$("#bdistrict10").append(spanh);
                                 	  }else if(tapwhere==4){
                                 	  	$("#bstreet10").append(spanh);
                                 	  }
                                 	  
                                 }
							} else if(data.result.meta.code == 301) {

							}
						},
						error: function(data) {
							console.log(data);
							//						plus.nativeUI.closeWaiting();
						}
					});
			}
			
			function bselAddresslast(parentNo){
//				alert(parentNo);
				$.ajax({
						type: 'post',
						url: ur + '/mobile/getAddress',
						headers: {
							"X-Token": localStorage.token
						},
						data: {
							"jdaddressVO.parentId": parentNo,
						},
						dataType: 'json',
						success: function(data) {
							console.log(data);
							if(data.result.meta.code == 200) {
                                 if(data.result.data.length>0){
                                 	 $('.bselectStreet').css('display','block');
                                 	 for(var i=0;i<data.result.data.length;i++){
	                                 	  var spanh = $('<option value="'+data.result.data[i].name+'" id='+data.result.data[i].id+'>'+data.result.data[i].name+'</option>');
	                                 	  
	                                 	  	$("#bstreet10").append(spanh);
	                                 	  
                                 	  
                                     }
                                 }
                                 
							} else if(data.result.meta.code == 301) {

							}
						},
						error: function(data) {
							console.log(data);
							//						plus.nativeUI.closeWaiting();
						}
					});
			}
			
			
			
			
			$('.editerimg').on('click',function(){
				$(this).parents('.editor_address_d').css('display','none');
				$('.ednameno').css('visibility','hidden');
             	$('.edphoneno').css('visibility','hidden');
             	$('.edquyuno').css('visibility','hidden');
             	$('.eddeno').css('visibility','hidden');
			})
			
			/*编辑地址*/
			$('.editor_add_save').on('click',function(){
               $(this).parents('.my_address_sing').attr('.id');
//				alert($('#street10').val());
//				alert($('.selectStreet').css('display'));
				if($('.editor_name_in').val()==""){
					$('.ednameno').css('visibility','visible');
					
					$('.edphoneno').css('visibility','hidden');
					
					$('.edquyuno').css('visibility','hidden');
					$('.eddeno').css('visibility','hidden');
				}else if($('.editor_phone_in').val()==""){
					
					$('.ednameno').css('visibility','hidden');
					$('.edquyuno').css('visibility','hidden');
					$('.eddeno').css('visibility','hidden');
					$('.edphoneno').css('visibility','visible');
				}else if(!hm.test($('.editor_phone_in').val())){
					
					$('.ednameno').css('visibility','hidden');
					$('.edquyuno').css('visibility','hidden');
					$('.eddeno').css('visibility','hidden');
					$('.edphoneno').css('visibility','visible');
					$('.edphoneno').text('X请检查您的联系方式');
				}else if($('#bprovince10').val()==''||$('#bcity10').val()==''||$('#bdistrict10').val()==''){
					$('.edphoneno').css('visibility','hidden');
					$('.ednameno').css('visibility','hidden');					
					$('.eddeno').css('visibility','hidden');
					$('.edquyuno').css('visibility','visible');
				}else if($('#bstreet10').val()=='' && $('.bselectStreet').css('display')=='block'){
					$('.edphoneno').css('visibility','hidden');
					$('.ednameno').css('visibility','hidden');					
					$('.eddeno').css('visibility','hidden');
					$('.edquyuno').css('visibility','visible');
				}else if($('.editer_de').val()==''){
					$('.edphoneno').css('visibility','hidden');
					$('.ednameno').css('visibility','hidden');
					$('.edquyuno').css('visibility','hidden');				
					$('.eddeno').css('visibility','visible');
				}else{
				    
					   var ssqj;
						if($('.bselectStreet').css('display') == 'block'){
						   ssqj = $('#bprovince10').val()+' '+$('#bcity10').val()+' '+$('#bdistrict10').val()+' '+$('#bstreet10').val();;					  
						}else if($('.bselectStreet').css('display') == 'none'){
						   ssqj = $('#bprovince10').val()+' '+$('#bcity10').val()+' '+$('#bdistrict10').val();					  
						}
				   
//				   if($('.bjmore').css('color')=='rgb(255, 255, 255)'){
//				   	var defu = 0;
//				   }else if($('.bjmore').css('color')=='rgb(255, 83, 80)'){
//				   	var defu = 1;
//				   }
				$.ajax({
					type: 'post',
					url:ur+'/mobilemember/frontmember/saveAddressByAdd',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					data: {
						"addressVO.isDefault":defu,
						"addressVO.area": ssqj,
						"addressVO.city": '',
						"addressVO.detail": $('.editer_de').val(),
						"addressVO.memberId": "",
						"addressVO.phone": $('.editor_phone_in').val(),
						"addressVO.postCode": '',
						"addressVO.province": '',
						"addressVO.reciver": $('.editor_name_in').val(),
						"addressVO.tel": '',					
						"addressVO.id":sessionStorage.wyshopeditorw
					},
					dataType: 'json',
					success: function(data) {
						console.log(JSON.stringify(data));
                         if(data.result.meta.code==200){
                         	$('.ednameno').css('visibility','hidden');
                         	$('.edphoneno').css('visibility','hidden');
                         	$('.edquyuno').css('visibility','hidden');
                         	$('.eddeno').css('visibility','hidden');
							$('.editor_address_d').css('display','none');
							$('.address_all_con').html('');
                            showlist();
						 }else if(data.result.meta.code==301){
						 	
						 }else if(data.result.meta.code==202){
						 	
						 }
					},
					error: function(data) {
						console.log(data);
					}
				});
			}	
				
			});
			
			//编辑现有收货地址
			$('.bjmore').on('click',function(){
				defu = 1;
//				alert($(this).css('color'));
				 if($(this).css('color')=='rgb(255, 255, 255)'){
				   	$(this).css({'background-color':'white','color':'#ff5350'});
				   }else if($(this).css('color')=='rgb(255, 83, 80)'){
				   	$(this).css({'background-color':'#ff5350','color':'white'});
				   }
			});
			
			
			//新建收货地址
			$('.xjmore').on('click',function(){
//				alert($(this).css('color'));
				 if($(this).css('color')=='rgb(255, 255, 255)'){
				   	$(this).css({'background-color':'white','color':'#ff5350'});
				   }else if($(this).css('color')=='rgb(255, 83, 80)'){
				   	$(this).css({'background-color':'#ff5350','color':'white'});
				   }
			});
			
			
			$('.creat_name_in').focus(function(){
				$('.crnameno').css('visibility','hidden');
			});
			$('.creat_phone_in').focus(function(){
				$('.crphoneno').css('visibility','hidden');
			});
			$('.crdetails').focus(function(){
				$('.crdeno').css('visibility','hidden');
			});
			
			
			
			var hm = /^1[34578]\d{9}$/;
			/*新建地址*/
			$('.address_save').on('click',function(){

//				$(this).parents('.my_address_sing').attr('.id');
//                 alert($('#street10').val());
//				alert($('.selectStreet').css('display'));
				if($('.creat_name_in').val()==""){
					$('.crnameno').css('visibility','visible');
					$('.crphoneno').css('visibility','hidden');
					$('.crquyuno').css('visibility','hidden');
					$('.crdeno').css('visibility','hidden');
				}else if($('.creat_phone_in').val()==""){
					$('.crnameno').css('visibility','hidden');
					$('.crquyuno').css('visibility','hidden');
					$('.crdeno').css('visibility','hidden');
					$('.crphoneno').css('visibility','visible');
				}else if(!hm.test($('.creat_phone_in').val())){
					$('.crnameno').css('visibility','hidden');
					$('.crquyuno').css('visibility','hidden');
					$('.crdeno').css('visibility','hidden');
					$('.crphoneno').css('visibility','visible');
					$('.crphoneno').text('X请检查您的联系方式');
				}else if($('#province10').val()==''||$('#city10').val()==''||$('#district10').val()==''){
					$('.crphoneno').css('visibility','hidden');
					$('.crnameno').css('visibility','hidden');					
					$('.crdeno').css('visibility','hidden');
					$('.crquyuno').css('visibility','visible');
				}else if($('#street10').val()=='' && $('.selectStreet').css('display')=='block'){
					$('.crphoneno').css('visibility','hidden');
					$('.crnameno').css('visibility','hidden');					
					$('.crdeno').css('visibility','hidden');
					$('.crquyuno').css('visibility','visible');
				}else if($('.crdetails').val()==''){
					$('.crnameno').css('visibility','hidden');
					$('.crphoneno').css('visibility','hidden');
					$('.crquyuno').css('visibility','hidden');					
					$('.crdeno').css('visibility','visible');
				}else{
				   $('.crnameno').css('visibility','hidden');
					$('.crphoneno').css('visibility','hidden');
					$('.crquyuno').css('visibility','hidden');
					$('.crdeno').css('visibility','hidden');
				     var ssqj;
					if($('.selectStreet').css('display') == 'block'){
					   ssqj = $('#province10').val()+' '+$('#city10').val()+' '+$('#district10').val()+' '+$('#street10').val();;					  
					}else if($('.selectStreet').css('display') == 'none'){
					   ssqj = $('#province10').val()+' '+$('#city10').val()+' '+$('#district10').val();					  
					}
				   
				   if($('.xjmore').css('color')=='rgb(255, 255, 255)'){
				   	var defu = 0;
				   }else if($('.xjmore').css('color')=='rgb(255, 83, 80)'){
				   	var defu = 1;
				   }
//				alert(defu);
				$.ajax({
					type: 'post',
					url:ur+'/mobilemember/frontmember/saveAddressByAdd',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					data: {
						"addressVO.isDefault":defu,
						"addressVO.area": ssqj,
						"addressVO.city": '',
						"addressVO.detail": $('.crdetails').val(),
						"addressVO.memberId": "",
						"addressVO.phone": $('.creat_phone_in').val(),
						"addressVO.postCode": '',
						"addressVO.province": '',
						"addressVO.reciver": $('.creat_name_in').val(),
						"addressVO.tel": '',
						
//						"addressVO.id":sessionStorage.wyshopeditorw
					},
					dataType: 'json',
					success: function(data) {
						console.log(JSON.stringify(data));
                         if(data.result.meta.code==200){
                         
							$('.creat_address_d').css('display','none');
							 $('.address_all_con').html('');
                            showlist();
                            
						 }else if(data.result.meta.code==301){
						 	
						 }else if(data.result.meta.code==202){
						 	
						 }
					},
					error: function(data) {
						console.log(data);
					}
				});
			}	
				
			});
			
			
			
			
			/*修改密码*/
			$('.modefy_submit_div').on('click',function(){
				if($('.oldpass').val()==''){
					$('.mtips_old').css('visibility','visible');
					
					$('.mtips_new1').css('visibility','hidden');
					$('.mtips_new2').css('visibility','hidden');
				}else if($('.newpass1').val()==''){
					$('.mtips_new1').css('visibility','visible');
					
					$('.mtips_old').css('visibility','hidden');
					$('.mtips_new2').css('visibility','hidden');
				}else if($('.newpass2').val()==''){
					$('.mtips_new2').css('visibility','visible');
					
					$('.mtips_old').css('visibility','hidden');
					$('.mtips_new1').css('visibility','hidden');
				}else if($('.newpass2').val()!=$('.newpass1').val()){
					$('.mtips_new2').text('请输入相同密码');
					$('.mtips_new2').css('visibility','visible');
					
					$('.mtips_old').css('visibility','hidden');
					$('.mtips_new1').css('visibility','hidden');
				}else{
					
					$('.mtips_old').css('visibility','hidden');
					$('.mtips_new1').css('visibility','hidden');
					$('.mtips_new2').css('visibility','hidden');
					$('.mtips_new2').css('visibility','hidden');
					$.ajax({
							type: "post",
							url: ur + "/mobilemember/frontmember/updatePassword",
							dataType: 'json',
							headers:{
								'x-token':localStorage.wyshoptoken
							},
							data: {
								'memberVO.password': $('.oldpass').val(),
								'newPassword': $('.newpass2').val(),
							},
							success: function(data) {
								console.log(JSON.stringify(data) + '修改密码');
								if(data.result.meta.code == "200") {
									$('.mmoditips').css('visibility','visible');
									$('.mmoditips').text('修改密码成功');
									//									mui.back();
								} else if(data.result.meta.code == "201"){
									$('.mmoditips').css('visibility','visible');
									$('.mmoditips').text('您输入的原密码不符');
								}else {
									$('.mmoditips').css('visibility','visible');
									$('.mmoditips').text('请检查您输入的信息');
								}
							},
							error: function(e) {
								console.log(e + '登录失败');
								mui.toast('请检查您的网络...');
							}
						});
					
				}
			})
			
			
			$('.wyshopshou').on('click',function(){
				window.location.href='../home/home.html';
			});
			
			$('.delete1or-n, .delete1-n').on('click',function(){
				$(this).parents('.alldiv').css('display','none');
			})
			
			$('.delete1-i').on('click',function(){
				$(this).parents('.alldiv').css('display','none');
			})
			
			$('.wuliucan').on('click',function(){
				$(this).parents('.mineloogwuliu').css('display','none');
			})
			
			//点击确认订单接口
			$('.confirmOrdersure').on('tap',function(){
				
							//				alert(thisid);
					$.ajax({
						url: ur + '/mobilemember/frontOrderOperation/cofrimOrder',
						type: 'post',
						headers: {
							"X-Token": localStorage.token
						},
						dataType: 'json',
						data: {
							"orderVO.id": localStorage.sureorderid,
							/*"id": '40288051594f367a015963128b240033',*/
						},
						success: function(data) {
//									alert(3)
							
						},
						error: function(data) {

							console.log(data);
						}
					})
			})
			
			
			
			/*订单点击确认收货*/
			$('.order_all').on('tap','.confirmOrder',function(){
				localStorage.sureorderid = $(this).parents('.order_dan').attr('oid');
				$('.confirmOrderdiv').show(0);
			});
			
			
			/*订单点击*/
			$('.order_all').on('click','.mbuttom1',function(){
				localStorage.sureorderid = $(this).parents('.order_dan').attr('oid');
				localStorage.sureorder = $(this).parents('.order_dan').attr('onum');
				if($(this).text()=='立即支付'){
					window.location.href='../cart/pay.html';
				}else if($(this).text()=='提醒发货'){
					$('.minetxfgoods').show(0);

				}else if($(this).text()=='确认收货'){
					$('.minesureget').show(0);
				}
			});
			
			
			
			$('.order_all').on('click','.mbuttom2',function(){
				localStorage.sureorderid = $(this).parents('.order_dan').attr('oid');
				if($(this).text()=='取消订单'){
					$('.minedorder').show(0);
					
				}else if($(this).text()=='申请退款'){
					$('.mbackkdiv').show(0);

				}else if($(this).text()=='查看物流'){
					$('.mineloogwuliu').show(0);
					lookwuliu();
				}else if($(this).text()=='删除订单'){
					$('.minedeleorder').show(0);
					
				}
			});
			
			
			$('.order_all').on('click','.lookdetails',function(){
     	           localStorage.sureorderid = $(this).parents('.order_dan').attr('oid');
     	           window.location.href='../goods/orderDetalis.html';
//   	           alert(localStorage.sureorderid);
            })
			
			
			
			$('.txfgoods').on('click',function(){
					txordergoods();
				});
			
			$('.msureget').on('click',function(){
					suregetgoods();
				});

			$('.delete1or-y').on('click',function(){
					deleteorder();
			});
					
			$('.mbackkdivsub').on('click',function(){
						if($('.mbackkt').val()==''){
						$('.mbackkdivtips').css('visibility','visible');
					    }else{
					      	backkorder();
					    }
			});
			
			$('.mdeleordersure').on('click',function(){
						deleorderid();
			});
			
			$('.mbackkt').focus(function(){
				$('.mbackkdivtips').css('visibility','hidden');
			})
			
			
			
			//查看物流
			function lookwuliu(){
				$.ajax({
					url: ur + '/mobilemember/frontOrder/getOrderShipInfo',
					type: 'POST',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					dataType: 'json',
					data: {
						"orderVO.id":localStorage.sureorderid
//						"orderVO.id": "644",
					},
					success: function(data) {
						alert(data.result.meta.code)
						if(data.result.meta.code == 201) {
							$('.logMain1').css('display', 'block');
						} else if(data.result.meta.code == 200) {
							$('.log-number').text(data.result.data.showapi_res_body.mailNo);
							$('.log-complan').text(data.result.data.showapi_res_body.expTextName);
							$('.log-phone').text(data.result.data.showapi_res_body.tel);
							var le = data.result.data.showapi_res_body.data;
							for(var i = 0; i < data.result.data.showapi_res_body.data.length; i++) {
								var context = replaceAll(JSON.stringify(data.result.data.showapi_res_body.data[i].context), '"', '');
									var divP = $('<div class="logMain" >'+
						 				'<div class="log-le yuandian1" id="log'+i+'"></div>'+
						 				'<div class="log-ri" style="width: 500px;">'+
						 					'<p class="wuliuw">'+context+'</p>'+
											'<p class="wuliut">'+JSON.stringify(data.result.data.showapi_res_body.data[i].time)+'</p>'+
						 				'</div>'+
						 			'</div>');
									$('.log-main').append(divP);
									$('.wuliuw').css('color','#151515');
									if(i==0){
										$('#log'+i).removeClass('yuandian1');
										$('#log'+i).addClass('yuandian');
									}else if (i == data.result.data.showapi_res_body.data.length-1){
										$('#log'+i).parent().css('border','none')
									}
							}
						}
					},
					error: function(data) {
						console.log(data);
					}
				})
			}
			function replaceAll(str, replaceKey, replaceVal) {
				var reg = new RegExp(replaceKey, 'g'); //g就是代表全部 
				return str.replace(reg, replaceVal || '');
			}
			//查看物流结束
			
			//删除订单
			function deleorderid(){
				$.ajax({
					url: ur + '/mobilemember/frontOrderOperation/orderByDel',
					type: 'post',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					dataType: 'json',
					data: {
						"orderVO.id": localStorage.sureorderid,
						/*"id": '40288051594f367a015963128b240033',*/
					},
					success: function(data) {
						console.log(data);
						if(data.result.meta.code==200){
							orderList();
							$('.minedeleorder').css('display','none');
						}
						
					},
					error: function(data) {
						console.log(data);
					}
				})
			}
			
			
			//申请退款
			function backkorder(){
				$.ajax({
					type:"post",
					url:ur+"/mobilemember/frontOrderOperation/refundAmount",
					ddataType:'json',
					headers: {
							'X-Token': localStorage.wyshoptoken,
						},
					data: {
							'orderVO.id': localStorage.sureorderid,
							'remark':$('.mbackkt').val()
						},
					success:function(data){
						console.log(data);
						if(data.result.meta.code==200){
							$('.mbackkdiv').css('display','none');
							orderList();
						}else if(data.result.meta.code==202){
							
						}					
					},
					error:function(data){
						console.log(data);
					}
			});
			}
			
			
			//确认收货
			function suregetgoods(){
				 
				 $.ajax({
						url: ur + '/mobilemember/frontOrderOperation/confirmReceipt',
						type: 'post',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						dataType: 'json',
						data: {
							"orderVO.id": localStorage.sureorderid,
							/*"id": '40288051594f367a015963128b240033',*/
						},
						success: function(data) {
							console.log(data);
							
							//							all.fadeOut(1000);
							if(data.result.meta.code==200){
                          	$('.minesureget').css('display','none');
                          	orderList();
                          }
						},
						error: function(data) {
							console.log(data);
						}
					})
			}
			
			
			
			//取消订单
			function deleteorder(){
				$.ajax({
					url: ur + '/mobilemember/frontOrderOperation/cancel',
					type: 'post',
					headers: {
						"X-Token": localStorage.wyshoptoken
					},
					dataType: 'json',
					data: {
						"orderVO.id": localStorage.sureorderid,
						/*"id": '40288051594f367a015963128b240033',*/
					},
					success: function(data) {
                          if(data.result.meta.code==200){
                          	$('.minedorder').css('display','none');
                          	orderList();
                          }
                          
					},
					error: function(data) {

						console.log(data);
					}
				})
			}
			
			
			
			//提醒发货
			function txordergoods(){
//				alert(11);
				$.ajax({
						url: ur + '/mobilemember/frontOrderOperation/remind',
						type: 'post',
						headers: {
							"X-Token": localStorage.wyshoptoken
						},
						dataType: 'json',
						data: {
							"orderByRemindId": localStorage.sureorderid,
							
						},
						success: function(data) {
							console.log(data);
                          if(data.result.meta.code==200){
                          	$('.minetxfgoods').css('display','none');
                          }
							
							
						},
						error: function(data) {
							console.log(data);
						}
					})
			}
			
});